package sync_config

import (
	syncConfigDto "news_for_deepseek_interface/dto/admin/sync_config"
	"news_for_deepseek_interface/model"
)

func Count(params syncConfigDto.CountRequest) (count int64, err error) {

	where := map[string]interface{}{}

	if params.TypeClassifyId != 0 {
		where["type_classify_id"] = params.TypeClassifyId
	}

	if params.BusinessClassifyId != 0 {
		where["business_classify_id"] = params.BusinessClassifyId
	}

	if err = model.GetInstance().DB.Debug().
		Model(&model.NewsModel{}).
		Where(where).
		Where("id > ?", params.StartId).
		Where("sync_status = ?", 0).
		Count(&count).Error; err != nil {
		return
	}

	return
}
